<template>
	<view class="_abbr">
		<view class="public">
			<view class="detail">
				<view class="main_body_view main_body_view_title">
					<u-row>
						{{dataForm.workOrderId}}
					</u-row>
				</view>
				<view class="main_body_view main_body_view_view">
					客户：{{dataForm.customerCompanyName}}
				</view>
				<view class="main_body_view main_body_view_view">
					时间：{{dataForm.preArriveCustomerTime|formatDate('MM-dd HH:mm') || ''}}
				</view>
				<view class="main_body_view">
					联系：{{dataForm.customerCompanyConnUsername || ''}}/{{dataForm.customerCompanyConnUserTel || ''}}
				</view>
				<view class="main_body_view">地址：{{dataForm.province}}/{{dataForm.city}}/{{dataForm.district}}</view>
				<view class="main_body_view">{{dataForm.recycleAddress||''}}</view>
				<text class="main_body_view">备注：{{dataForm.dispWorkOrderRemark||"暂无其它备注"}}</text>
			</view>
		</view>
		<view class="public">
			<view>现场要求：<text :key="item" v-for="item in dataForm.recycleLiveRequest">{{item.remark}}/</text>
			</view>
			<view>其他：{{dataForm.recycleLiveRequestOther||"无"}}</view>
			<view>现场数据：<text :key="item" v-for="item in dataForm.recycleDataDestroyType">{{item.remark}}/</text>
			</view>
			<view>其他：{{dataForm.recycleDataDestroyTypeOther||"无"}}</view>
			<view>检测要求：<text :key="item" v-for="item in dataForm.testDeviceRequest">{{item.remark}}/</text>
			</view>
			<view>其他：{{dataForm.testDeviceRequestOther||"无"}}</view>
			<view>检测数据：<text :key="item" v-for="item in dataForm.testDataDestroyType">{{item.remark}}/</text>
			</view>
			<view>其他：{{dataForm.testDataDestroyTypeOther||"无"}} </view>
			<view>携带设备：<text :key="item" v-for="item in dataForm.recycleTakeDevice">{{item.remark}}/</text>
			</view>
			<view>其他：{{dataForm.recycleTakeDeviceOther||"无"}}</view>
		</view>
		<view class="public">
			<view>
				<view class="scan-item item1" style="margin-bottom: 10px;">
					<input
						:focus="isFocus" 
						placeholder="扫描或输入二维码" 
						:value="detailForm.deviceQr" 
						@blur="confirm" 
						type="text" 
						class="input">
					<view class="right-icon">
						<view class="icon" @click="doScan1">
							<u-icon size="30" name="scan"></u-icon>
						</view>
					</view>
				</view>
				<view class="content">
					<view v-for="item in detailForm.deviceModelMediaVos" :key="item.mediaId">
						<u-image 
							:showLoading="true" 
							:src="item.fileUrl" 
							width="100px"
							height="100px"
							>
						</u-image>
					</view>
					<view class="device">
						<view style="font-size: 18px;">
							{{detailForm.deviceModel || ''}}
						</view>
						<view>
							{{ detailForm.deviceType || ''}} {{ detailForm.deviceBrand || ''}} {{detailForm.deviceModel || ''}}
						</view>
					</view>
				</view>
				<view class="item-container">
					<view
					  v-for="(item, index) in attachmentList"
					  :key="index"
					  class="item"
					>
					  <view :style="{ 'text-decoration': (item.ifAlreadyDisassembly === 1) ? 'line-through' : 'none' }">
						{{ item.deviceProperties }}: {{ item.deviceModel}}
						<span v-if="!item.ifAlreadyDisassembly" @click="handleDismissAttachment(item)" class="cancel">拆卸</span>
					  </view>
					</view>
					<u-modal
						:show="isDismissAttachmentOpen" 
						title="拆卸"
						@confirm="handleConfirmAdd"
						@cancel="handleCancel" 
						show-cancel-button
						mask-close-able
						>
						<view>
							<u-form :model="attachmentForm" ref="uForm">
								<u-form-item>
									 <view class="scan-item item1">
									 	<input
									 		:focus="isFocusAttachQr" 
									 		placeholder="扫描或输入二维码" 
									 		:value="attachmentForm.deviceQr"
									 		@blur="confirmDeviceQr" 
									 		type="text" 
									 		class="input">
									 	<view class="right-icon">
									 		<view class="icon" @click="doScanDeviceQr">
									 			<u-icon size="30" name="scan"></u-icon>
									 		</view>
									 	</view>
									 </view>
								</u-form-item>
								<u-form-item v-if="ifOnlyOne">
									 <view class="scan-item item1">
									 	<input
									 		:focus="isFocusSn" 
									 		placeholder="扫描或输入Sn" 
									 		:value="attachmentForm.deviceSn"
									 		@blur="confirmDeviceSn" 
									 		type="text" 
									 		class="input">
									 	<view class="right-icon">
									 		<view class="icon" @click="doScanDeviceSn">
									 			<u-icon size="30" name="scan"></u-icon>
									 		</view>
									 	</view>
									 </view>
								</u-form-item>
								<u-form-item v-if="ifOnlyOne">
									<text class="attach-item" v-if="!attachmentForm.deviceStatus" @click="deviceStatusShow = true;">设备状态</text>
									<text class="attach-item" v-else @click="deviceStatusShow = true;">{{attachmentForm.deviceStatus}}</text>
									<u-picker :show="deviceStatusShow" :columns="deviceStatusList" @confirm="deviceStatusConfirm" keyName="label" @cancel="cancel"></u-picker>
								</u-form-item>
								<u-form-item v-if="ifOnlyOne">
									<text class="attach-item" v-if="!attachmentForm.deviceCondition" @click="deviceConditionShow = true;">设备成色</text>
									<text class="attach-item" v-else @click="deviceConditionShow = true;">{{attachmentForm.deviceCondition}}</text>
									<u-picker :show="deviceConditionShow" :columns="deviceConditionList" @confirm="deviceConditionConfirm" keyName="label" @cancel="cancel"></u-picker>
								</u-form-item>
								<view v-if="!ifOnlyOne">
									<u--input 
										placeholder="输入数量" 
										height="10rpx" 
										v-model="containerParams.count"
										>
									</u--input>
								</view>
								<u-form-item>
									<u-input 
										v-model="attachmentForm.remark" 
										placeholder="请输入备注"
										/>
								</u-form-item>
								<view v-if="ifOnlyOne">
									<view>设备照片</view>
									<view>
										<u-upload 
											:fileList="fileList1" 
											@afterRead="afterRead" 
											@delete="deletePic" 
											name="1" 
											:maxCount="1">
										</u-upload>
									</view>
								</view>
							</u-form>
						</view>
					</u-modal>
				</view>
				<!-- <view class="scan-item item1" style="margin-top: 10px;">
					<u-input 
						v-model="deviceFit.name" 
						@tap="handleSelectDevice" 
						placeholder="选择设备" 
						border="false" 
						:show-action="false"
						>
					</u-input>
				</view> -->
			</view>
		</view>
		
		<view class="public">
			<view>
				<u-row justify="space-between">
					<u-col span="5">
						<!-- <u-button type="primary" @click="submitDevice" text="提交" :disabled="buttonDisabled"></u-button> -->
					</u-col>
					<u-col span="5">
						<u-button type="primary" @click="sub" text="结束" :disabled="buttonDisabled"></u-button>
					</u-col>
				</u-row>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '@/utils/request';
	import pickerSearch from '@/compoments/pickerSearch.vue'
	export default {
		name: 'main',
		components: {pickerSearch},
		onLoad(options) {
			uni.showLoading({
				title: "正在加载中"
			})
			this.BaseUrl = getApp().globalData.baseURL;
			// 监听生成签字的图片地址
			uni.$on('q-sign', img => {
				//其他操作 比如上传签字图片
				uni.uploadFile({
					url: `${this.BaseUrl}system/oss/upload`, //仅为示例，非真实的接口地址
					filePath: img,
					name: 'file',
					header: {
						Authorization: uni.getStorageSync("token")
					},
					success: (oss) => {
						const data = JSON.parse(oss.data);
						this.$nextTick();
					}
				});
			})
			uni.hideLoading()
		},
		onUnload() {
			uni.$off('q-sign') //移除监听事件
		},
		data() {
			return {
				deviceStatusShow: false, 
				deviceConditionShow: false,
				detailAttachment: {},
				ifOnlyOne:true,
				containerParams: {},
				isFocusAttachQr: false,
				isFocusSn: false,
				fileList1: [], //设备照片
				deviceImages: {
					deviceQr: '',
					mediaType: "1",
					mediaName: '设备照片',
					fileUrls: []
				},
				deviceStatusList: [], // 设备状态列表
				deviceConditionList: [], //设备成色列表
				attachmentForm: {
					deviceQr: '',
					deviceSn: ''
				},
				isDismissAttachmentOpen: false, //配件弹窗
				attachmentList: [], //配件表
				isFocusSn:true,
				deviceSpecsNew: undefined,
				oneCodeDevice: {
					items: [{}],
				}, // 一物一码设备数组
				oneCodeForm: {
					workOrderId: undefined,
					items: [{}],
				}, // 一物一码数组
				containerForm: {
					orderId: undefined,
					items: [{}],
				}, // 容器码数组
				containerDevice: {
					items: [{}],
				}, // 容器码设备数组
				deviceFit: {}, //选择设备(拆卸)
				detailForm: {
					deviceQr: '',
				}, // 设备详情
				ifOnlyOne: true, // 是否一物一码
				isFocus: true, // 二维码是否聚焦
				isFocusOneCode: true,
				isFocusContainer: true, //容器码是否聚集
				deviceForm: {}, //选择设备传递的数据
				requestParams: {},
				buttonDisabled: false,
				proud: "",
				BaseUrl: "",
				dataForm: {}, // 数据工单
				historyList: [], //过程工单
				subForm: {
					workOrderId: null,
					method: ""
				}, //提交工单
				WorkOrderMediaBo: [], //工单文件
				writeFlag: undefined,
				fileList1: [], //设备照片
				deviceImages: {
					deviceQr: '',
					mediaType: "1",
					mediaName: '设备照片',
					fileUrls: []
				},
			}
		},
		methods: {
			// 确定设备状态
			deviceStatusConfirm(e) {
				this.attachmentForm.deviceStatus = e.value[0].label
				this.deviceStatusShow = false
			},
			// 确定设备成色
			deviceConditionConfirm(e) {
				this.attachmentForm.deviceCondition = e.value[0].label
				this.deviceConditionShow = false
			},
			// 拆卸配件
			handleChangeAttachment() {
				request({
					url: "system/detailAttachment",
					method:"PUT",
					data: {
						...this.detailAttachment,
						ifAlreadyDisassembly: 1,
					},
				}).then(res => {
					this.getAttachmentList()
				})
			},
			// 新增配件
			handleConfirmAdd() {
				this.deviceImages.deviceQr = this.attachmentForm.deviceQr
				request({
					url: "system/deviceDetailSnap",
					method:"POST",
					data: {
						...this.detailAttachment,
						...this.attachmentForm,
						ffDeviceQr: this.detailForm.deviceQr,
						workOrderId: this.dataForm.workOrderId,
						deviceFlowStatus: "拆解中-拆解",
					}
				}).then(res => {
					if (res.code === 200) {
						uni.showToast({
							title:"新增成功",
							icon:'none'
						})
						this.isDismissAttachmentOpen = false
						this.handleChangeAttachment()
					}  else {
						uni.showToast({
							title: res.msg,
							icon:'none'
						})
					}
				})
				// 设备照片
				if (this.deviceImages.fileUrls.length > 0) {
				    request({
				        url: 'system/modelMedia',
				        method: 'POST',
				        data:this.deviceImages
				    }).then(res => {
				        this.fileList1 = []
						this.deviceImages = {
							deviceQr: '',
							mediaType: "1",
							mediaName: '设备照片',
							fileUrls: []
						}
				    });
				}
				// this.handleChangeAttachment()
			},
			// 设备状态列表
			getDeviceStatus() {
				request({
					url: "system/dict/data/list",
					method:"GET",
					data: {
						dictType: "devicestatus"
					},
				}).then(res => {
					this.deviceStatusList = res.rows.map((item, index) => ({
					    label: item.dictValue,
					    id: index
					}));
					this.deviceStatusList = [this.deviceStatusList]
				})
			},
			// 设备成色列表
			getDeviceCondition() {
				request({
					url: "system/dict/data/list",
					method:"GET",
					data: {
						dictType: "device_condition"
					},
				}).then(res => {
					this.deviceConditionList = res.rows.map((item, index) => ({
					    label: item.dictValue,
					    id: index
					}));
					this.deviceConditionList = [this.deviceConditionList]
				})
			},
			// 取消拆卸
			handleCancel() {
				this.isDismissAttachmentOpen = false
				this.attachmentForm = {}
			},
			// 拆卸配件
			handleDismissAttachment(item) {
				this.isDismissAttachmentOpen = true
				this.getDeviceCondition()
				this.getDeviceStatus()
				this.detailAttachment = item
			},
			// 获取配件表
			getAttachmentList() {
				request({
					url: "system/detailAttachment/list",
					method:"GET",
					data: {
						ffDeviceQr: this.detailForm.deviceQr,
					},
				}).then(res => {
					this.attachmentList = res.rows
				})
			},
			removeOneCode(index) {
				this.oneCodeForm.items.splice(index, 1)
			},
			removeContainerCode(index) {
				this.containerForm.items.splice(index, 1)
			},
			// 获取选择设备返回的参数
			otherFun(item) {
				if (item) {
					this.deviceFit = item;
				}
			},
			// 一物一码获取选择设备返回的参数
			otherFunOneCode(item, index) {
				const storedIndex = uni.getStorageSync('oneCodeIndex')
				if (item && storedIndex !== null) {
					this.$set(this.oneCodeDevice.items, storedIndex, item);
					this.oneCodeForm.items[storedIndex].deviceModelId = item.deviceModelId
				}
			},
			// 容器码获取选择设备返回的参数
			otherFunContainer(item, index) {
				const storedIndex = uni.getStorageSync('containerIndex')
				if (item && storedIndex !== null) {
					this.$set(this.containerDevice.items, storedIndex, item);
					this.containerForm.items[storedIndex].deviceModelId = item.deviceModelId
					this.containerForm.items[storedIndex].unit = this.deviceForm.unit || 'PCS'
				}
			},
			// 添加一行一物一码设备
			addOneCode() {
				this.oneCodeForm.items.push({
					workOrderId: this.oneCodeForm.workOrderId || "",
					deviceModelId: undefined,
					deviceQr: undefined,
					deviceFlowStatus:this.dataForm.workOrderStatus,
					ffDeviceQr: this.detailForm.deviceQr
				});
			},
			// 添加一行容器码设备
			addContainer() {
				this.containerForm.items.push({
					orderId: this.containerForm.orderId || "",
					deviceModelId: undefined,
					containerQr: undefined,
					count: undefined,
					unit: 'PCS',
					operate: "增加",
					operatePhase: this.dataForm.workOrderStatus,
					operatePhaseId: this.dataForm.workOrderStatusId,
					ffDeviceQr: this.detailForm.deviceQr
				});
			},
			// 二维码确定
			confirm(e) {
				this.isFocus = false
				if (e.detail.value) {
					this.detailForm.deviceQr = e.detail.value
					this.getDeviceData()
				}
			},
			// 配件二维码确定
			confirmDeviceQr(e) {
				this.isFocusAttachQr = false
				if(e.detail.value) {
					this.attachmentForm.deviceQr = e.detail.value
					this.isFocusAttachQr = true
					// 判断容器码
					let deviceQr = e.detail.value.trim().toUpperCase(); // 去除空格并转换为大写
					if (deviceQr.startsWith('CINO-C')) {
						this.ifOnlyOne = false
						this.containerParams.containerQr = e.detail.value
					}
				}
			},
			// sn
			confirmDeviceSn(e) {
				if(e.detail.value) {
					this.attachmentForm.deviceSn = e.detail.value
				}
			},
			// 一物一码确定
			confirmOneCode(e, index) {
				this.isFocusOneCode = false
				this.oneCodeForm.items[index].deviceQr = e.detail.value
			},
			// sn确定
			confirmSn(e, index) {
				this.isFocusSn = false
				this.oneCodeForm.items[index].deviceSn = e.detail.value
			},
			// 容器码确定
			confirmContainer(e, index) {
				this.isFocusContainer = false
				this.containerForm.items[index].containerQr = e.detail.value
			},
			// 获取单个设备详情
			getDeviceData() {
				request({
					method: "GET",
					url: `system/detail/${this.detailForm.deviceQr}`,
				}).then(res => {
					if (res.data) {
						this.detailForm = res.data
						this.getData(this.detailForm.workOrderId);
						this.detailForm.deviceFlowStatus = this.dataForm.workOrderStatus
						this.detailForm.workOrderId = this.dataForm.workOrderId || ""
						// const specsArray = JSON.parse(res.data.deviceSpecs || "[]");
						// this.deviceSpecsNew = specsArray.map(spec => spec[2]).join(' ');
						this.getAttachmentList()
						// this.oneCodeForm.workOrderId = this.dataForm.workOrderId
						// this.oneCodeForm.items[0] = {
						// 	workOrderId: this.dataForm.workOrderId || "",
						// 	deviceModelId: '',
						// 	deviceQr: '',
						// 	deviceFlowStatus:this.dataForm.workOrderStatus,
						// 	ffDeviceQr: res.data.deviceQr
						// }
						// this.containerForm.orderId = this.dataForm.workOrderId
						// this.containerForm.items[0] = {
						// 	orderId: this.dataForm.workOrderId || "",
						// 	deviceModelId: '',
						// 	containerQr: '',
						// 	count: '',
						// 	unit: "PCS",
						// 	operate: "增加",
						// 	operatePhase: this.dataForm.workOrderStatus,
						// 	operatePhaseId: this.dataForm.workOrderStatusId,
						// 	ffDeviceQr: res.data.deviceQr
						// }
					} else {
						this.detailForm.deviceFlowStatus = this.dataForm.workOrderStatus
						this.detailForm.workOrderId = this.dataForm.workOrderId || ""
						// this.oneCodeForm.workOrderId = this.dataForm.workOrderId
						// this.oneCodeForm.items[0] = {
						// 	workOrderId: this.dataForm.workOrderId || "",
						// 	deviceModelId: '',
						// 	deviceQr: '',
						// 	deviceFlowStatus:this.dataForm.workOrderStatus,
						// 	ffDeviceQr: this.detailForm.deviceQr
						// }
						// this.containerForm.orderId = this.dataForm.workOrderId
						// this.containerForm.items[0] = {
						// 	orderId: this.dataForm.workOrderId || "",
						// 	deviceModelId: '',
						// 	containerQr: '',
						// 	count: '',
						// 	unit: "PCS",
						// 	operate: "增加",
						// 	operatePhase: this.dataForm.workOrderStatus,
						// 	operatePhaseId: this.dataForm.workOrderStatusId,
						// 	ffDeviceQr: this.detailForm.deviceQr
						// }
					}
				})
			},
			// 跳转选取设备
			handleSelectDevice(index) {
				const workId = this.dataForm.workOrderId
				uni.setStorageSync('oneCodeIndex', index);
				const item = this.oneCodeDevice.items[index];
				this.otherFun(item, index);
				uni.navigateTo({
					url: 'selectDevice?workId=' + workId
				});
			},
			// 跳转一物一码
			handleOneCodeDevice(index) {
				const workId = this.dataForm.workOrderId
				uni.setStorageSync('oneCodeIndex', index);
				const item = this.oneCodeDevice.items[index];
				this.otherFunOneCode(item, index);
				uni.navigateTo({
					url: 'deviceFit/oneCodeDevice?workId=' + workId
				});
			},
			// 跳转容器码设备
			handleContainerDevice(index) {
				const workId = this.dataForm.workOrderId
				uni.setStorageSync('containerIndex', index);
				const item = this.oneCodeDevice.items[index];
				this.otherFunContainer(item, index);
				uni.navigateTo({
					url: 'deviceFit/containerDevice?workId=' + workId
				});
			},
			// 扫码配件二维码
			doScanDeviceQr() {
				uni.scanCode({
					success: (res) =>{
						this.attachmentForm.deviceQr = res.result
						this.isFocusAttachQr = true
						let deviceQr = res.result.trim(); // 去除空格
						if (deviceQr.startsWith('CINO-C')) {
							this.ifOnlyOne = false
							this.containerParams.containerQr = deviceQr;
						}
					}
				})
			},
			// sn
			doScanDeviceSn() {
				uni.scanCode({
					success: (res) =>{
						console.log(res.result)
						this.attachmentForm.deviceSn = res.result
						this.isFocusSn = true
					}
				})
			},
			// 扫码二维码
			doScan1() {
				uni.scanCode({
					success: (res) =>{
						console.log(res.result)
						this.detailForm.deviceQr = res.result
						this.getDeviceData()
					}
				})
			},
			// 扫描一物一码
			doScanOneCode(index) {
				uni.scanCode({
					success: (res) => {
						this.oneCodeForm.items[index].deviceQr = res.result
						this.$forceUpdate()
					}
				})
			},
			// 扫描sn
			doScanSn(index) {
				uni.scanCode({
					success: (res) =>{
						this.oneCodeForm.items[index].deviceSn = res.result
						this.$forceUpdate()
					}
				})
			},
			// 扫描容器码
			doScanContainer(index) {
				uni.scanCode({
					success: (res) =>{
						this.containerForm.items[index].containerQr = res.result
						this.$forceUpdate()
					}
				})
			},
			goSign(num) {
				this.writeFlag = num;
				uni.navigateTo({
					url: '/uni_modules/q-sign/pages/q-sign'
				})
			},
			// 提交设备
			submitDevice() {
				if (this.deviceFit.deviceModelId) {
					this.reset()
				} else {
					this.detailForm.deviceModelId = this.deviceFit.deviceModelId;
					request({
						url: "system/deviceDetailSnap",
						method: "post",
						data: this.detailForm
					}).then(res => {
						if (res.code === 200) {
							uni.showToast({
								title: "提交成功",
								icon: 'none'
							});
							this.reset()
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							});
						}
					})
				}
			},
			reset() {
				this.detailForm = {}
				this.oneCodeDevice = {
					items: [{}],
				}, // 一物一码设备数组
				this.oneCodeForm = {
					workOrderId: undefined,
					items: [{}],
				}, // 一物一码数组
				this.containerForm = {
					orderId: undefined,
					items: [{}],
				}, // 容器码数组
				this.containerDevice = {
					items: [{}],
				}
				this.deviceFit = {}
				this.attachmentList = []
			},
			// 提交工单
			sub() {
				this.subForm.workOrderId = this.dataForm.workOrderId
				this.subForm.method = "end_diss"
				const self = this; // 保存当前对象的引用
				// 提交
				uni.showModal({
					title: '确定结束拆卸吗',
					success: function (res) {
						if (res.confirm) {
							// 提交
							request({
								url: 'system/order',
								method: "PUT",
								data: self.subForm
							}).then(res => {
								uni.reLaunch({
									url: '/pages/view/dismantle/index'
								})
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.forEach((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url, event.name)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url, name) {
				return new Promise((resolve, reject) => {
					uni.$u.http.upload(`${this.BaseUrl}system/oss/upload`, {
						params: {},
						/* 会加在url上 */
						// #ifdef APP-PLUS || H5
						files: [], // 需要上传的文件列表。使用 files 时，filePath 和 name 不生效。App、H5（ 2.6.15+）
						// #endif
						filePath: url, // 要上传文件资源的路径。
						// 注：如果局部custom与全局custom有同名属性，则后面的属性会覆盖前面的属性，相当于Object.assign(全局，局部)
						custom: {
							auth: true
						}, // 可以加一些自定义参数，在拦截器等地方使用。比如这里我加了一个auth，可在拦截器里拿到，如果true就传token
						name: 'file', // 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
						// #ifdef H5 || APP-PLUS
						timeout: 60000, // H5(HBuilderX 2.9.9+)、APP(HBuilderX 2.9.9+)
						// #endif
						header: {
							Authorization: uni.getStorageSync("token")
						},
						/* 会与全局header合并，如有同名属性，局部覆盖全局 */
						formData: {}, // HTTP 请求中其他额外的 form data
						// 返回当前请求的task, options。请勿在此处修改options。非必填
						getTask: (task, options) => {},
					}).then((res) => {
						// console.log(res);
						if (name == 1) {
							this.deviceImages.fileUrls.push(
								res.data.data.url.replace("blob:", ""),
							)
						}
						resolve(res.data.data.url)
						// 返回的res.data 已经进行JSON.parse
					}).catch(err => {

					})
				})
			},
			// 请求数据
			getData(workId) {
				request({
					method: "GET",
					url: `system/order/${workId}`
				}).then(res => {
					this.dataForm = res.data;
					this.subForm.workOrderId = res.data.workOrderId;
					this.proud = res.data.workOrderStatusId - 0;
					// this.checkImages(res.data.workOrderMediaVos)
				})
			},
			// 存储图片
			checkImages(imageForms) {
				for (let dataElement of imageForms) {
					switch (dataElement.mediaType) {
						case "1": 
							if (dataElement.fileUrl !== null) {
								this.fileList1.push({
									type: "image",
									url: dataElement.fileUrl,
									status: "success",
									name: "",
									message: "",
									thumb: "",
									size: 60489
								})
							}
						default:
							continue;
					}
				}
			},
		},
		filters: {
			formatDate: function(value, args) {
				var dt = new Date(value);
				if (args == 'yyyy-M-d') { // yyyy-M-d
					let year = dt.getFullYear();
					let month = dt.getMonth() + 1;
					let date = dt.getDate();
					return `${year}-${month}-${date}`;
				} else if (args == 'yyyy-M-d H:m:s') { // yyyy-M-d H:m:s
					let year = dt.getFullYear();
					let month = dt.getMonth() + 1;
					let date = dt.getDate();
					let hour = dt.getHours();
					let minute = dt.getMinutes();
					let second = dt.getSeconds();
					return `${year}-${month}-${date} ${hour}:${minute}:${second}`;
				} else if (args == 'yyyy-MM-dd') { // yyyy-MM-dd
					let year = dt.getFullYear();
					let month = (dt.getMonth() + 1).toString().padStart(2, '0');
					let date = dt.getDate().toString().padStart(2, '0');
					return `${year}-${month}-${date}`;
				} else { // yyyy-MM-dd HH:mm:ss
					let year = dt.getFullYear();
					let month = (dt.getMonth() + 1).toString().padStart(2, '0');
					let date = dt.getDate().toString().padStart(2, '0');
					let hour = dt.getHours().toString().padStart(2, '0');
					let minute = dt.getMinutes().toString().padStart(2, '0');
					let second = dt.getSeconds().toString().padStart(2, '0');
					return `${month}-${date} ${hour}:${minute}`;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	._abbr {
		width: 100%;
		height: 100%;
		// position: absolute;
		background-color: rgba(244, 249, 254, 1);

		.public {
			background-color: #ffffff;
			margin: 20upx;
			border-radius: 2%;
			padding: 20upx;
			border:1px solid;
			border-color:rgba(0, 124, 233, 0.4);
			.main_body_view {
				margin: 10upx;
			}
			.device-border {
				border: 1px solid #eee; 
				border-radius: 3px; 
				padding: 4px;
				margin-bottom: 6px;
			}
			.back-icon {
			    background-color: black;
			    width: 24px;
			    height: 24px;
			    border-radius: 12px;
				position: relative;
			    margin: auto;
			    .add-icon {
					position: absolute;
					top: -1px;
					left: 6px;
			        color: #ffffff;
			        font-size: 18px;
			        line-height: 24px; /* 让文本垂直居中 */
					text-align: center; /* 让文本水平居中 */
			    }
			}
			.button {
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
			.main_body_view_title {
				border-bottom: 1px solid black;
				margin-bottom: 10upx;
			}
			.total-count {
				display: flex;
				align-items: center;
				justify-content: center; 
				margin-top: 10px; 
				font-size: 16px;
			}
			.scan-item {
				// margin-top: 10px;
				.input {
					margin: 10px 0 10px 6px;
					width: 100%;
				}
				.right-icon {
					position: relative;
					box-sizing: border-box;
					position: sticky;
					top: 0;
					z-index: 999;
					display: flex;
					overflow: hidden;
					justify-content: space-around;
					background: rgb(255, 255, 255);
					margin: 6px;
					.scan {
						position: absolute;
						top: 10upx;
						right:14upx;
					}
				}
				.device {
					display: flex;
					margin: 10px 0;
					justify-content: space-between;
				}
				.device-item {
					display: flex;
					align-items: center;
					flex-direction: column;
				}
				.test-scan {
					border: 1px solid #eee;
					padding: 8px;
				}
				.button {
					text-align: center; 
					margin-top: 40rpx;
					display: flex;
				}
			}
			.content {
				display: flex; 
				align-items: center; 
				justify-content: center;
				.device {
					// text-align: center; 
					flex: 1; 
					margin-left: 10px;
					font-size: 14px;
				}
			}
			.item-container {
			  .item {
			    box-sizing: border-box; /* 让边框和填充不会增加项目的宽度 */
			    padding: 5px; /* 可以根据需要调整间距 */
			    .cancel {
			      margin-left: 20px;
			      cursor: pointer;
			      color: #409eff;
			    }
				.item1 {
					display: flex; 
					align-items: center;
				}
			  }
			  .attach-item {
			  	border: 1px solid #eee; 
			  	padding: 8px 10px;
			  }
			}
			.item1 {
				display: flex; 
				border: 1px solid #eee;
			}
			.user_for {
				display: flex;
			}
			.line_for {
				width: 4rpx;
				height: 24rpx;
				margin: 0 20rpx 10rpx;
			}
			.line_radio {
				width: 20rpx;
				height: 20rpx;
				border-radius: 50%;
				position: relative;
				left: 50%;
				transform: translateX(-50%);
				top: 0;
			}
			.right_box {
				padding: 0rpx 20rpx 20rpx 20rpx;
			}
			.desc {
				font-size: 30rpx;
				display: flex;
				margin-top: 20rpx;
				align-items: center;
			}
		}
		.write {
			display: flex;
			justify-content: space-around;
			.im {
				width: 300rpx;
				image {
					width: 200rpx;
					height: 300rpx;
					position: relative;
					left: 30rpx;
				}
			}
		}
	}
</style>
